package io.terminus.filter;

import com.baomidou.mybatisplus.core.parser.ISqlParserFilter;
import com.baomidou.mybatisplus.core.parser.SqlParserHelper;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.reflection.MetaObject;

/**
 * @author li.chunlong lcl253-137@alibaba-inc.com
 * @desc TODO 不知道怎么配合多租户使用
 *  对多租户、动态表名的排除都有作用
 * @date 2021-09-27
 */
public class SqlParserFilterImpl implements ISqlParserFilter {

    @Override
    public boolean doFilter(MetaObject metaObject) {
        String mappedStatementId = "io.terminus.mapper.UserMapper.selectById";

        MappedStatement mappedStatement = SqlParserHelper.getMappedStatement(metaObject);
        return mappedStatementId.equals(mappedStatement.getId());
    }
}
